/* SPDX-License-Identifier: GPL-2.0 */
#ifndef UTILS_STDDEF_H_
#define UTILS_STDDEF_H_

#include <utils/compiler_types.h>

#ifndef __ASSEMBLY__

#ifndef __always_inline
#define __always_inline inline
#endif

/**
 * sizeof_field(TYPE, MEMBER)
 *
 * @TYPE: The structure containing the field of interest
 * @MEMBER: The field to return the size of
 */
#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))

/**
 * offsetofend(TYPE, MEMBER)
 *
 * @TYPE: The type of the structure
 * @MEMBER: The member within the structure to get the end offset of
 */
#define offsetofend(TYPE, MEMBER) \
    (offsetof(TYPE, MEMBER)	+ sizeof_field(TYPE, MEMBER))

#endif /* !__ASSEMBLY__ */
#endif /* !UTILS_STDDEF_H_ */
